package com.ruoyi.chengkao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.chengkao.domain.CkExamType;
import com.ruoyi.chengkao.service.ICkExamTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 报考类型信息Controller
 * 
 * @author xiaosong
 * @date 2025-03-10
 */
@Api(tags = "成人高考-考试类型管理")
@RestController
@RequestMapping("/chengkao/examType")
public class CkExamTypeController extends BaseController
{
    @Autowired
    private ICkExamTypeService ckExamTypeService;

    /**
     * 查询报考类型信息列表
     */
    @PreAuthorize("@ss.hasPermi('chengkao:examType:list')")
    @GetMapping("/list")
        @ApiOperation("成人高考考试类型管理 - 分页查询列表")
    public TableDataInfo list(CkExamType ckExamType)
    {
        startPage();
        List<CkExamType> list = ckExamTypeService.selectCkExamTypeList(ckExamType);
        return getDataTable(list);
    }

    //查询全部数据的接口
    @GetMapping("/all")
        @ApiOperation("成人高考考试类型管理 - 查询所有数据")
    public AjaxResult getAll()
    {
        List<CkExamType> list = ckExamTypeService.selectCkExamTypeAll();
        return success(list);
    }

    /**
     * 导出报考类型信息列表
     */
    @PreAuthorize("@ss.hasPermi('chengkao:examType:export')")
    @Log(title = "报考类型信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
        @ApiOperation("成人高考考试类型管理 - 导出数据")
    public void export(HttpServletResponse response, CkExamType ckExamType)
    {
        List<CkExamType> list = ckExamTypeService.selectCkExamTypeList(ckExamType);
        ExcelUtil<CkExamType> util = new ExcelUtil<CkExamType>(CkExamType.class);
        util.exportExcel(response, list, "报考类型信息数据");
    }

    /**
     * 获取报考类型信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('chengkao:examType:query')")
    @GetMapping(value = "/{id}")
        @ApiOperation("成人高考考试类型管理 - 根据ID获取详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ckExamTypeService.selectCkExamTypeById(id));
    }

    /**
     * 新增报考类型信息
     */
    @PreAuthorize("@ss.hasPermi('chengkao:examType:add')")
    @Log(title = "报考类型信息", businessType = BusinessType.INSERT)
    @PostMapping
        @ApiOperation("成人高考考试类型管理 - 新增数据")
    public AjaxResult add(@RequestBody CkExamType ckExamType)
    {
        return toAjax(ckExamTypeService.insertCkExamType(ckExamType));
    }

    /**
     * 修改报考类型信息
     */
    @PreAuthorize("@ss.hasPermi('chengkao:examType:edit')")
    @Log(title = "报考类型信息", businessType = BusinessType.UPDATE)
    @PutMapping
        @ApiOperation("成人高考考试类型管理 - 修改数据")
    public AjaxResult edit(@RequestBody CkExamType ckExamType)
    {
        return toAjax(ckExamTypeService.updateCkExamType(ckExamType));
    }

    /**
     * 删除报考类型信息
     */
    @PreAuthorize("@ss.hasPermi('chengkao:examType:remove')")
    @Log(title = "报考类型信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
        @ApiOperation("成人高考考试类型管理 - 删除数据")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ckExamTypeService.deleteCkExamTypeByIds(ids));
    }
}
